package com.dongdongshop.service.impl;

import com.dongdongshop.mapper.UserMapper;
import com.dongdongshop.pojo.User;
import com.dongdongshop.pojo.UserExample;
import com.dongdongshop.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;


@Service
@com.alibaba.dubbo.config.annotation.Service
public class UserServiceImpl implements UserService {


    @Autowired
    private UserMapper userMapper;
    @Override
    public Boolean selectByName(String name,String pwd) {
        if(name.equals("") || name == null){
            return false;
        }
        UserExample userExample = new UserExample();
        UserExample.Criteria criteria = userExample.createCriteria();
        criteria.andNameEqualTo(name);
        List<User> users = userMapper.selectByExample(userExample);
        if(users == null || users.size() == 0){
            return false;
        }
        User user = users.get(0);
        if(user.getPwd() == pwd){
            return true;
        }
        return false;
    }
}
